package elitech.vietnam.myfashion.view;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import elitech.vietnam.myfashion.MainActivity;
import elitech.vietnam.myfashion.R;

public class FollowListView extends LinearLayout implements View.OnClickListener {

	private MainActivity mContext;
	private LinearLayout mBtnFollower, mBtnFollowing, mLayList, mMainMenu;
	private ImageButton mFloatMenu;
	private FollowerView mFollowerView;
	public FollowingView mFollowingView;

	public FollowListView(MainActivity context) {
		super(context);
		this.mContext = context;
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if (inflater != null) {
			inflater.inflate(R.layout.followlist, this);
		}
		
		this.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		
		mBtnFollower = (LinearLayout) findViewById(R.id.followlist_layBtnFollower);
		mBtnFollowing = (LinearLayout) findViewById(R.id.followlist_layBtnFollowing);
		mLayList = (LinearLayout) findViewById(R.id.followlist_layList);
		mMainMenu = (LinearLayout) findViewById(R.id.main_menu);
		mFloatMenu = (ImageButton) findViewById(R.id.followlist_btnFloatMenu);
		
		mMainMenu.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mContext.callMenu();
			}
		});
		mFloatMenu.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mContext.callMenu();
			}
		});
		
		mBtnFollower.setOnClickListener(this);
		mBtnFollowing.setOnClickListener(this);
		
		mBtnFollowing.setBackgroundColor(Color.TRANSPARENT);
		mBtnFollower.setBackgroundColor(getResources().getColor(R.color.dark_orange));
		
		mFollowerView = new FollowerView(mContext);
		mFollowerView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		mFollowingView = new FollowingView(mContext);
		mFollowingView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		
		mLayList.addView(mFollowingView);
		
//		mContext.changeTitle(mContext.getString(R.string.followlist), true);
		
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.followlist_layBtnFollowing:
			mBtnFollowing.setBackgroundColor(Color.TRANSPARENT);
			mBtnFollower.setBackgroundColor(getResources().getColor(R.color.dark_orange));
			mLayList.removeAllViews();
			mLayList.addView(mFollowingView);
			mFollowingView.clearFocus();
			break;
		case R.id.followlist_layBtnFollower:
			mBtnFollower.setBackgroundColor(Color.TRANSPARENT);
			mBtnFollowing.setBackgroundColor(getResources().getColor(R.color.dark_orange));
			mLayList.removeAllViews();
			mLayList.addView(mFollowerView);
			mFollowerView.clearFocus();
			break;
		}
	}
	
	public void ChangeTab(int tabIndex) {
		switch (tabIndex) {
		case 1:
			mBtnFollower.performClick();
			break;
		case 2:
			mBtnFollowing.performClick();
		default:
			break;
		}
	}

	public void onResume() {
		
	}
	
}
